home *** CD-ROM | disk | FTP | other *** search
- Path: news.mira.net.au!news
- From: davidw@werple.net.au (David White)
- Newsgroups: comp.lang.c++
- Subject: Re: HELP: Getting the address of member functions
- Date: 1 Apr 1996 20:10:32 +1000
- Organization: Werple Internet, Melbourne
- Message-ID: <4joa2o$7a9@werple.net.au>
- References: <4jndbi$m12@lucy.swin.edu.au>
- NNTP-Posting-Host: werplez.mira.net.au
-
- 079519@bud.swin.edu.au (John Joseph Newbigin) writes:
-
- >I am writing a serial port driver class in BC3.1. It is interrupt driven so I
- >need an interrupt function that can be set to the required int. vector. I can do
- >this using a normal function but it can not access the class data and so needs
- >global vars. and hence, defeats the purpose of a class.
-
- >Does anyone know how to get the address of member functions so I can overcome this
- >problem?
-
- You have to use a static or global variable. Remember that a non-static
- member function serves all instances of the class. Therefore, it needs to
- know when it is called which instance it is being called for. This is done
- by an implicit argument, the instance's address ('this'), being passed to
- it. Since the processor only knows the interrupt handler's address, not
- the instance address as well, it cannot call the member function in the
- way it requires.
-
- David White
- davidw@werple.mira.net.au
-